# @Desc    : 工具类获取配置文件的内容
# @Author  : meihongliang  
# @Time    : 2025-03-01 13:23
import os
from datetime import datetime

import yaml


def get_config():
    # 使用模块路径和__file__ 来动态规避路径迁移问题
    util_path = os.path.dirname(__file__)
    # 假设config.yaml位于util模块的 当前目录下(./)
    config_path = os.path.join(util_path, './', 'config.yaml')
    with open(config_path, 'r') as file:
        config = yaml.safe_load(file)

        # 访问配置值
    # print(lw_config['lose_weight'])  # 输出: True
    # print(lw_config['lose_weight']['execl_2024'])  # 输出: localhost
    return config


def get_now_time_str():
    config = get_config()
    return datetime.now().strftime(config['lose_weight']['time_format'])


def get_2024_execl():
    config = get_config()
    return config['lose_weight']['execl_2024']


def get_2025_execl():
    config = get_config()
    return config['lose_weight']['execl_2025']


if __name__ == '__main__':
    get_config()
    print(get_now_time_str())
    print(get_2024_execl())
    print(get_2025_execl())
